//home模块的配置项
//引入req 接口函数
import {
    reqCategoryList,reqGetBannerList,reqGetFloorList
} from "@/api";
//console.log(reqCategoryList); 解构赋值内容为箭头函数所有内容
const state = {
    //接收三级联动数据
    categoryList: [],
    //轮播图数据
    bannerList:[],
    //floor数据
    FloorList:[],
};
const mutations = {
    //修改三级联动数据
    CATEGORYLIST(state, categoryList) {
        state.categoryList = categoryList;
        //哪个兔崽子改了后台数据
        state.categoryList.pop();
    },
    //修改轮播图数据
    BANNERLIST(state,bannerList){
         state.bannerList = bannerList;
         //console.log(state.bannerList);
    },
    //修改floor数据
    GETFLOORLIST(state,FloorList){
       state.FloorList = FloorList
    }

};
const actions = {
    //通过api发请求,调用接口函数,获取服务器数据
    //解构赋值呗
    async categoryList({
        commit
    }) {
        let res = await reqCategoryList();
        //console.log(res);
        if (res.code == 200) {
            commit("CATEGORYLIST", res.data);
        }
    },
    //获取轮播图
   async getBannerList({commit}){
     let res1 = await reqGetBannerList();
      //console.log(res1);
       if(res1.code == 200){
        commit('BANNERLIST',res1.data);
       }
      
    },
      //获取floor数据
   async getFloorList({commit}){
    let res1 = await reqGetFloorList();
     //console.log(res1);
      if(res1.code == 200){
       commit('GETFLOORLIST',res1.data);
      }
     
   }

};
const getters = {};
export default {
   namespaced:true,
    state,
    mutations,
    actions,
    getters,
}